feat: Structured Generative Model Configuration#56
Open
carlesonielfa wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a structured LLMConfig model to replace plain string model identifiers in agent configurations, enabling centralized environment-configurable defaults and optional reasoning configuration while keeping legacy stored configs loadable via coercion.
Changes:
- Added
hyperforge.llm_config(LLMConfig,LLMField, defaults, reasoning helpers) and updated many agent config schemas to useLLMFieldwith centralized defaults. - Added DB/Alembic-oriented migration helpers to rename model IDs inside nested stored JSONB configs, plus unit/integration tests.
- Updated manager and several agent runtime call sites to pass the correct model identifier string (
.model_id) to external request models.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds hyperforge-restricted as a dependency entry. |
| hyperforge/tests/unit/arag/test_llm_migration_utils.py | Tests JSON-walk replacement and a DB-backed migration path. |
| hyperforge/tests/unit/arag/test_llm_config.py | Tests string→LLMConfig coercion and reasoning resolution behavior. |
| hyperforge/src/hyperforge/manager.py | Accepts `str |
| hyperforge/src/hyperforge/llm_config.py | Defines LLMConfig/LLMField, reasoning config types, and env-driven defaults. |
| hyperforge/src/hyperforge/db/llm_migration_utils.py | Implements JSONB walk/replace + multi-table migration helper for model renames. |
| hyperforge/src/hyperforge/context/config.py | Migrates context agent config model fields from str to LLMField. |
| hyperforge/src/hyperforge/context/agent.py | Updates rephrase API signature to accept ModelParam. |
| agents/summarize/src/hyperforge_summarize/config.py | Converts summarize agent model field to LLMField with defaults. |
| agents/summarize/src/hyperforge_summarize/agent.py | Uses .model_id when building ChatModel. |
| agents/smart/src/hyperforge_smart/config.py | Converts planner/executor model fields to LLMField with defaults. |
| agents/smart/src/hyperforge_smart/agent.py | Uses .model_id when building ChatModel for tool selection. |
| agents/restricted/src/hyperforge_restricted/config.py | Converts decision model to LLMField with reasoning-tier default. |
| agents/restart/src/hyperforge_restart/config.py | Converts model to LLMField and adds field metadata. |
| agents/rephrase/src/hyperforge_rephrase/config.py | Converts rephrase model to LLMField with centralized default. |
| agents/related/tests/test_related.py | Updates tests to construct RelatedAgentConfig with LLMConfig and asserts .model_id. |
| agents/related/src/hyperforge_related/config.py | Converts related agent model to LLMField with default factory. |
| agents/related/src/hyperforge_related/agent.py | Import order change (no functional change). |
| agents/nucliadb/src/hyperforge_nucliadb/basic_ask_config.py | Converts generative_model to LLMField with centralized defaults. |
| agents/nucliadb/src/hyperforge_nucliadb/basic_ask_agent.py | Uses .model_id for AskRequest.generative_model. |
| agents/nucliadb/src/hyperforge_nucliadb/ask/config.py | Converts configuration_model to LLMField with fast-tier default. |
| agents/nucliadb/src/hyperforge_nucliadb/advanced_ask_config.py | Converts generative_model to LLMField with centralized default. |
| agents/nucliadb/src/hyperforge_nucliadb/advanced_ask_agent.py | Uses .model_id for AskRequest.generative_model. |
| agents/mcp/src/hyperforge_mcp/config.py | Converts MCP model fields to LLMField with tiered defaults. |
| agents/mcp/src/hyperforge_mcp/agent.py | Uses .model_id for ChatModel / CreateMessageResult model fields. |
| agents/generate/src/hyperforge_generate/config.py | Converts generate agent model to LLMField with centralized default. |
| agents/generate/src/hyperforge_generate/agent.py | Uses .model_id when building ChatModel. |
| agents/external/src/hyperforge_external/config.py | Converts external-call agent model to LLMField with reasoning-tier default. |
| agents/conditional/src/hyperforge_conditional/conditional.py | Converts conditional agent model to LLMField with reasoning-tier default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces plain
strmodel fields in agent configs with a structuredLLMConfigtype supporting reasoning configuration, centralized defaults, and automated model migrations — fully backwards compatible with existing stored configs.Approach
Uses a Pydantic
Annotatedtype withBeforeValidatorto transparently coerce plain strings to `LLMConfigChanges
hyperforge/llm_config.pyLLMConfig,LLMField,LLMDefaults,ReasoningConfighyperforge/db/llm_migration_utils.pywalk_and_replace(),migrate_llm_models()for Alembicstr→LLMField, widget moved toLLMConfig.model_idModelParam = str | LLMConfig, reasoning resolved and passed toChatModel.model_idCentralized Defaults (env-configurable)
Backwards Compatibility
"chatgpt-4.1"(legacy JSON) → auto-coerced toLLMConfig(model_id="chatgpt-4.1")_type: "llm_config"discriminator enables future Alembic model rename migrations